﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data;
using System.Data.SqlClient;

/// <summary>
/// Summary description for GCatalogDAL
/// </summary>
public class GCatalogDAL
{
    DataAccess acc = new DataAccess();
	public GCatalogDAL()
	{
		//
		// TODO: Add constructor logic here
		//
	}

    internal DataTable getAllGCatalog()
    {
        return acc.executeSelect("getAllGiftCatalog");
    }

    internal bool insertGiftCatalog(string Name)
    {
        SqlParameter[] paraList = new SqlParameter[1];
        paraList[0] = new SqlParameter("@CG_Name", SqlDbType.NVarChar, 50);
        paraList[0].Value = Name;
        int check = acc.executeModifier("insertGiftCatalog", paraList);
        if (check > 0)
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    internal bool updateGiftCatalogStatus(int id)
    {
        SqlParameter[] paraList = new SqlParameter[1];
        paraList[0] = new SqlParameter("@CG_ID", SqlDbType.Int);
        paraList[0].Value = id;
        int check = acc.executeModifier("updateGiftCatalogStatus", paraList);
        if (check > 0)
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    internal bool updateGiftCatalog(int id, string name)
    {
        SqlParameter[] paraList = new SqlParameter[2];
        paraList[0] = new SqlParameter("@CG_ID", SqlDbType.Int);
        paraList[0].Value = id;
        paraList[1] = new SqlParameter("@CG_Name", SqlDbType.NVarChar, 50);
        paraList[1].Value = name;
        int check = acc.executeModifier("updateGiftCatalog", paraList);
        if (check > 0)
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    internal DataTable getCGiftByID(int id)
    {
        SqlParameter[] paraList = new SqlParameter[1];
        paraList[0] = new SqlParameter("CG_ID", SqlDbType.Int);
        paraList[0].Value = id;
        return acc.executeSelect("getCatalogGiftByID", paraList);
    }
}